[GreenDonut] Properly support ToBatchPageAsync with valueSelector#9324
Merged
michaelstaib merged 8 commits intomainfrom Mar 21, 2026
Merged
[GreenDonut] Properly support ToBatchPageAsync with valueSelector#9324michaelstaib merged 8 commits intomainfrom
michaelstaib merged 8 commits intomainfrom
Conversation
eda626f to
42593ca
Compare
tobias-tengler
commented
Mar 8, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a bug in the GreenDonut paging framework where ToBatchPageAsync with a valueSelector did not properly generate cursors for the projected items, because the cursor needed to be created from the source element rather than the projected value. The fix introduces an ElementCursorPage<TElement, TValue> concept that retains the mapping between original elements and projected items for cursor creation.
Changes:
Page<T>is refactored fromsealedtoabstract, with two new internal concrete implementations:ValueCursorPage<T>(for direct item→cursor mapping) andElementCursorPage<TElement, TValue>(for source element→cursor mapping when a value selector is used).ToBatchPageAsyncis updated to accept a nullablevalueSelector, usingElementCursorPagewhen a selector is provided to preserve the source→cursor relationship.- Migration documentation and tests are updated to reflect the API change from
new Page<T>(...)toPage<T>.Create(...).
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
GreenDonut.Data.Primitives/Page.cs |
Changed from sealed to abstract; added Page<T>.Create(...) factory methods delegating to ValueCursorPage<T> and ElementCursorPage<TElement,T> |
GreenDonut.Data.Primitives/ValueCursorPage.cs |
New internal class for pages where cursors are created directly from items |
GreenDonut.Data.Primitives/ElementCursorPage.cs |
New internal class for pages where cursors are created from source elements (supports valueSelector use case) |
GreenDonut.Data.EntityFramework/Extensions/PagingQueryableExtensions.cs |
Updated ToBatchPageAsync to support nullable valueSelector, uses ElementCursorPage when selector is provided; extracted CreatePageFlags helper |
HotChocolate/Data/test/Data.Tests/PagingHelperIntegrationTests.cs |
Added test for ToBatchPageAsync with valueSelector and ToConnectionAsync; added SeedMinimalAsync helper |
HotChocolate/Data/test/Data.Tests/QueryContextUnionProjectionTests.cs |
Updated to use new Page<T>.Create(...) factory method instead of removed public constructor |
website/src/docs/hotchocolate/v16/migrating/migrate-from-15-to-16.md |
Added migration guidance for the Page<T> constructor-to-factory-method change |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
42593ca to
33d8a42
Compare
… notes - Guard ToBatchPageAsync against null valueSelector when TElement != TValue to surface ArgumentNullException instead of InvalidCastException - Add backward pagination test (Last=2) with valueSelector and ToConnectionAsync - Expand v15→v16 migration guide with all Page/cursor/Edge API changes Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
904b03f to
c1925bf
Compare
This was referenced May 1, 2026
This was referenced May 4, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.